Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(css): add information on scope (at-rule) boundary behavior #37336

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

bayesian-intelligence
Copy link

Description

Add more details on @scope boundary behaviour.

Motivation

The default inclusivity / exclusivity behaviour is non-obvious. There is description of it in the MDN page, and no example showing how to invert the selectivity if needed. There is also nothing that explains that a scope limit can be used with an inline @scope.

Additional details

In this revision, the selectivity behaviour is described, and examples given of how to alter the behaviour if needed.

The universal child selector approach is recommended in this WG bug for the lower bound: w3c/csswg-drafts#6577 . It generalises to the upper bound.

Related issues and pull requests

Describes the inclusivity/exclusivity of @scope boundaries, and makes it clear that an inline @scope can be used just with a scope limit.
@bayesian-intelligence bayesian-intelligence requested a review from a team as a code owner December 22, 2024 05:55
@bayesian-intelligence bayesian-intelligence requested review from estelle and removed request for a team December 22, 2024 05:55
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed labels Dec 22, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Contributor

github-actions bot commented Dec 28, 2024

Preview URLs

Flaws (48)

URL: /en-US/docs/Web/CSS/@scope
Title: @scope
Flaw count: 48

  • macros:
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/Getting_started_with_the_web/CSS_basics
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps/What_is_CSS
    • Wrong xref macro used (consider changing which macro you use). Error processing path /en-US/docs/Learn/CSS/First_steps/Getting_started
    • and 43 more flaws omitted

(comment last updated: 2024-12-28 19:33:13)

@@ -23,6 +23,8 @@ The `@scope` at-rule contains one or more rulesets (termed **scoped style rules*
}
```

The scope's upper bound is inclusive and its lower bound is exclusive. To change this behavior, you can combine either selector with a universal child selector. For example, `@scope (scope root) to (scope limit > *)` would make both bounds inclusive, `@scope (scope root > *) to (scope limit)` would make both bounds exclusive, while `@scope (scope root > *) to (scope limit > *)` would give an exclusive upper bound and an inclusive lower bound.

Copy link
Member

@estelle estelle Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful information

This would be better placed in the description. This is the syntax section. The child selector portion is useful, but not required syntax. Also, the upper and lower bound is not yet defined, so is hard to parse here, but may be much more understandable if it comes after "The .article-body scope root selector defines the upper bound of the DOM tree scope in which the ruleset will be applied, and the figure scope limit selector defines the lower bound." (emphasis added)

@bsmth bsmth changed the title Patch 1 feat(css): add information on scope (at-rule) boundary behavior Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:CSS Cascading Style Sheets docs size/xs [PR only] 0-5 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants